$(function () {

    //初始化表格
    initTable();
});


function initTable() {
    var options = {
        url: prefix + "/list",
        createUrl: prefix + "/addInit",
        updateUrl: prefix + "/editInit/{id}",
        removeUrl: prefix + "/remove",
        sortName: "createTime",
        sortOrder: "desc",
        modalName: "角色",
        search: false,
        showExport: false,
        columns: [{
            checkbox: true
        },{
            field: 'roleId',
            title: '角色编号'
        },{
            field: 'roleCode',
            title: '角色编码',
            sortable: true
        },{
            field: 'roleName',
            title: '角色名称',
            sortable: true
        },{
            field: 'remark',
            title: '备注'
        },{
            field: 'createTime',
            title: '创建时间',
            sortable: true
        },{
            title: '操作',
            align: 'center',
            formatter: function(value, row, index) {
                var actions = [];
                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editFull(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="#" onclick="rule(\'' + row.roleId + '\')"><i class="fa fa-check-square-o"></i>数据权限</a> ');
                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.roleId + '\')"><i class="fa fa-remove"></i>删除</a>');
                return actions.join('');
            }
        }]
    }
    $.table.init(options);
}

/*角色管理-分配数据权限*/
function rule(roleId) {
    var url = prefix + '/rule/' + roleId;
    $.modal.open("分配数据权限", url);
}

function test() {
    var config = {
        url: "http://localhost:2035/biz/productEquity/queryProductBy",
        type: 'post',
        dataType: 'json',
        contentType:'application/json;charset=utf-8',
        data: '{"sign":"a8f54663a7b5e59422a967a67f2fdf2b26de707491f7693254d879683b7319ed11243a4db52c0e8411baae891905f0f8"}',
        success: function (result) {
            $.operate.saveSuccess(result);
        }
    }
    $.ajax(config);
    /*var url = "http://localhost:2035/biz/productEquity/queryProductBy";
    var data = "a8f54663a7b5e59422a967a67f2fdf2b26de707491f7693254d879683b7319ed11243a4db52c0e8411baae891905f0f8";
    $.post(url, data);*/
}